﻿using System;
using System.Windows.Navigation;
using AchievementSample.ViewModels;
using Microsoft.Phone.Controls;

namespace AchievementSample
{
    public partial class ItemPage : PhoneApplicationPage
    {
        public ItemPage()
        {
            InitializeComponent();
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (NavigationContext.QueryString.ContainsKey("idx"))
            {
                var ivm = DataContext as ItemViewModel;
                if (ivm != null)
                {
                    ivm.Achievement =
                        AppAchievements.Instance.AllAchievements[Convert.ToInt32(NavigationContext.QueryString["idx"])];
                }
            }
            base.OnNavigatedTo(e);
        }
    }
}